Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a polyfill implementation for the File.Move(string, string, bool) overload that was introduced in .NET Core 3.0, allowing the method to be used in earlier framework versions. The polyfill enables file moving with an overwrite parameter to control whether existing destination files should be replaced.
- Implements
File.Movewith overwrite parameter usingFile.Copyfollowed byFile.Delete - Adds conditional compilation for .NET Framework, .NET Standard, and .NET Core versions prior to 3.0
- Includes test coverage for scenarios where the destination exists and doesn't exist (both with overwrite=true)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| PolyShim/NetCore30/File.cs | Adds polyfill implementation of File.Move with overwrite parameter using Copy+Delete pattern |
| PolyShim.Tests/NetCore30/FileTests.cs | Adds unit tests for the new File.Move overload covering overwrite scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| File.Delete(sourceFileName); | ||
| } |
There was a problem hiding this comment.
The polyfill implementation is not atomic and could leave the file in both locations if File.Delete fails after File.Copy succeeds. Consider wrapping the delete in a try-catch and handling potential failures, or document this limitation. The standard File.Move is atomic on most filesystems.
| File.Delete(sourceFileName); | |
| } | |
| // WARNING: This polyfill is not atomic. If File.Delete fails after File.Copy succeeds, | |
| // the file may exist in both locations. The standard File.Move is atomic on most filesystems. | |
| try | |
| { | |
| File.Delete(sourceFileName); | |
| } | |
| catch (IOException ex) | |
| { | |
| // Optionally, handle or log the error here. | |
| // For now, rethrow to preserve original behavior. | |
| throw; | |
| } |
| catch | ||
| { | ||
| // Ignore | ||
| } |
There was a problem hiding this comment.
Generic catch clause.
| catch | ||
| { | ||
| // Ignore | ||
| } |
There was a problem hiding this comment.
Generic catch clause.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.